home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / prog_d / dacm.zip / DEMO / UNIT1.PAS < prev    next >
Pascal/Delphi Source File  |  1995-11-17  |  5KB  |  185 lines

  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls,DB, DBTables,DACMgr, TabNotBk, ExtCtrls, Grids,
  8.     DBGrids;
  9.  
  10. type
  11.   TForm1 = class(TForm)
  12.     VSSecurity1: TDACManager;
  13.     SecurityObject1: TSecurityObject;
  14.     TabbedNotebook1: TTabbedNotebook;
  15.     Memo1: TMemo;
  16.     LogOnBtn: TButton;
  17.     MaintenanceBtn: TButton;
  18.         PINBtn: TButton;
  19.     BuildBtn: TButton;
  20.     Form1Btn: TButton;
  21.     Form2Btn: TButton;
  22.     Form3Btn: TButton;
  23.     Form4Btn: TButton;
  24.     Label1: TLabel;
  25.     Label2: TLabel;
  26.     Label3: TLabel;
  27.     Label4: TLabel;
  28.     Label5: TLabel;
  29.     Label6: TLabel;
  30.         Label7: TLabel;
  31.     Label8: TLabel;
  32.     Label9: TLabel;
  33.     Label10: TLabel;
  34.     Label11: TLabel;
  35.     Label12: TLabel;
  36.         Label13: TLabel;
  37.     Label14: TLabel;
  38.     Label15: TLabel;
  39.     Label16: TLabel;
  40.     Button1: TButton;
  41.     Panel1: TPanel;
  42.         CurrentUser: TLabel;
  43.     Label17: TLabel;
  44.     SecurityLog: TTable;
  45.     DataSource1: TDataSource;
  46.         DBGrid1: TDBGrid;
  47.     Label18: TLabel;
  48.     Label19: TLabel;
  49.     Label20: TLabel;
  50.         procedure LogOnBtnClick(Sender: TObject);
  51.         procedure MaintenanceBtnClick(Sender: TObject);
  52.         procedure PINBtnClick(Sender: TObject);
  53.     procedure VSSecurity1BuildDAO(Sender: TObject);
  54.         procedure BuildBtnClick(Sender: TObject);
  55.         procedure Form1BtnClick(Sender: TObject);
  56.         procedure Form2BtnClick(Sender: TObject);
  57.         procedure Form3BtnClick(Sender: TObject);
  58.         procedure Form4BtnClick(Sender: TObject);
  59.     procedure VSSecurity1DACMEvent(const EventType: TSecurityEvents;
  60.             Info1: Longint; Info2: Byte);
  61.         procedure SecurityObject1Permissions(Sender: TObject);
  62.   private
  63.     { Private declarations }
  64.   public
  65.     { Public declarations }
  66.   end;
  67.  
  68. var
  69.   Form1: TForm1;
  70.  
  71. implementation
  72.  
  73. {$R *.DFM}
  74.  
  75. procedure TForm1.LogOnBtnClick(Sender: TObject);
  76. begin
  77. Security.LogOn;
  78. if Security.LoggedOn=True then caption:='Logged On' else caption:='LogOn Failed';
  79. end;
  80.  
  81. procedure TForm1.MaintenanceBtnClick(Sender: TObject);
  82. begin
  83. Security.Maintenance;
  84. end;
  85.  
  86. procedure TForm1.PINBtnClick(Sender: TObject);
  87. begin
  88. Security.ChangePIN;
  89.  
  90. end;
  91.  
  92. procedure TForm1.VSSecurity1BuildDAO(Sender: TObject);
  93. var
  94. OID:longint;
  95. begin
  96. Security.AppendObject('New Form','FormX',OID);
  97.  
  98. end;
  99.  
  100. procedure TForm1.BuildBtnClick(Sender: TObject);
  101. var
  102. OID:longint;
  103. begin
  104. Security.AppendObject('Form1','Form1',OID);
  105. Security.AppendObject('Form2','Form2',OID);
  106. Security.AppendObject('Form5','Form5',OID);
  107. Security.AppendObject('Form4','Form4',OID);
  108.  
  109. end;
  110.  
  111. procedure TForm1.Form1BtnClick(Sender: TObject);
  112. var
  113. p:TPermissions;
  114. begin
  115. p:=Security.CheckPermissions('Form1');
  116. if []   = p then caption:='Access Denied - You have no permissions'
  117.     else if ( p * [0,1,2,3,4]=[0,1,2,3,4])  then caption:='Access Granted - You have Read permissions'
  118.         else caption:='Access Denied - You do not have the right permissions'
  119.  
  120. end;
  121.  
  122. procedure TForm1.Form2BtnClick(Sender: TObject);
  123. var
  124. p:TPermissions;
  125. begin
  126. p:=Security.CheckPermissions('Form2');
  127. if [] = p then caption:='Access Denied - You have no permissions'
  128.     else if 0 in p then caption:='Access Granted - You have Read permissions'
  129.         else caption:='Access Denied - You do not have the right permissions'
  130.  
  131. end;
  132.  
  133. procedure TForm1.Form3BtnClick(Sender: TObject);
  134. var
  135. p:TPermissions;
  136. begin
  137. p:=Security.CheckPermissions('Form3');
  138. if [] = p then caption:='Access Denied - You have no permissions'
  139.     else if 2 in p then caption:='Access Granted - You have Modify permissions'
  140.         else caption:='Access Denied - You do not have the right permissions'
  141.  
  142. end;
  143.  
  144. procedure TForm1.Form4BtnClick(Sender: TObject);
  145. var
  146. p:TPermissions;
  147. begin
  148. p:=Security.CheckPermissions('Form4');
  149. if [] = p then caption:='Access Denied - You have no permissions'
  150.     else if 2 in p then caption:='Access Granted - You have Modify permissions'
  151.         else caption:='Access Denied - You do not have the right permissions'
  152.  
  153. end;
  154.  
  155. procedure TForm1.VSSecurity1DACMEvent(const EventType: TSecurityEvents;
  156.     Info1: Longint; Info2: Byte);
  157. var
  158. EType:string;
  159. begin
  160. if EventType=sLogOn then CurrentUser.Caption:='Current User: '+Security.UserName;
  161. case EventType of
  162. sLogOn:EType:='LoggedOn';
  163. sPermissions:EType:='Permission Check';
  164. sPINChange:EType:='PINChange';
  165. sMaintenance:EType:='Maintenance';
  166. sWrite:EType:='Writing Security Record';
  167. sOList:EType:='Updating Permissions';
  168. sDelete:EType:='Deleting Security Record';
  169. end;
  170. Panel1.Caption:='LastEvent: ' + EType;
  171. if SecurityLog.Active<>True then SecurityLog.Active:=True;
  172. with SecurityLog do
  173. begin
  174. AppendRecord([Security.UserName,EType,Now,Info1,Info2]);
  175. end;
  176. end;
  177.  
  178. procedure TForm1.SecurityObject1Permissions(Sender: TObject);
  179. begin
  180. if TSecurityObject(Sender).Permissions=[] then
  181. ShowMessage('The DACM has reported you have no permissions for this application, however you can continue for the moment');
  182. end;
  183.  
  184. end.
  185.